import java.util.ArrayList;
import java.util.Date;

public class RegularFlight
{
	private Date time;
	private int flightNumber;
	private int amountOfSeats;
	private ArrayList<SpecificFlight> specificFlights;
	
	public RegularFlight(Date time, int flightNumber, int amountOfSeats)
	{
		this.setTime(time);
		this.setFlightNumber(flightNumber);
		this.setAmountOfSeats(amountOfSeats);
		setSpecificFlights(new ArrayList<SpecificFlight>());
	}
	
	public void addSpecificFlight(Date date)
	{
		specificFlights.add(new SpecificFlight(this,date));
	}
	
	public void removeSpecificFlight(SpecificFlight flight)
	{
		specificFlights.remove(flight);
	}
	
	/**
	 * Searches in the array for a specificflight on the given date
	 * @param date
	 * @return if found return the specific flight else return null
	 */
	public SpecificFlight getSpecificFlightByDate(Date date)
	{
		for(int i=0;i<specificFlights.size();i++)
		{
			if(specificFlights.get(i).getDate().equals(date))
			{
				return specificFlights.get(i);
			}
		}
		
		return null;
	}

	public void setTime(Date time)
	{
		this.time = time;
	}

	public Date getTime()
	{
		return time;
	}

	public void setFlightNumber(int flightNumber)
	{
		this.flightNumber = flightNumber;
	}

	public int getFlightNumber()
	{
		return flightNumber;
	}

	public void setSpecificFlights(ArrayList<SpecificFlight> specificFlights)
	{
		this.specificFlights = specificFlights;
	}

	public ArrayList<SpecificFlight> getSpecificFlights()
	{
		return specificFlights;
	}

	public void setAmountOfSeats(int amountOfSeats)
	{
		this.amountOfSeats = amountOfSeats;
	}

	public int getAmountOfSeats()
	{
		return amountOfSeats;
	}
	
	
}
